Return to start page

Systems/Gui/Struct Check Box.j

Code

		
1			library AStructSystemsGuiCheckBox requires AStructSystemsGuiWidget, AStructSystemsGuiImage
2
3 private function onHitAction takes AWidget usedWidget returns nothing
4 call ACheckBox(usedWidget).setChecked(not ACheckBox(usedWidget).isChecked())
5 endfunction
6
7 struct ACheckBox extends AWidget
8 //static start members
9 private static string checkedImageFilePath
10 private static string uncheckedImageFilePath
11 //dynamic members
12 private boolean m_checked
13 //members
14 private AImage checkedImage
15
16 //dynamic members
17
18 public method setChecked takes boolean checked returns nothing
19 set this.m_checked = checked
20 if (checked) then
21 call this.checkedImage.setFile(ACheckBox.checkedImageFilePath)
22 else
23 call this.checkedImage.setFile(ACheckBox.uncheckedImageFilePath)
24 endif
25 endmethod
26
27 public method isChecked takes nothing returns boolean
28 return this.m_checked
29 endmethod
30
31 //methods
32
33 public static method create takes AMainWindow mainWindow, real x, real y, real sizeX, real sizeY, AWidgetOnTrackAction onTrackAction, boolean checked returns thistype
34 local thistype this = thistype.allocate(mainWindow, x, y, sizeX, sizeY, onHitAction, onTrackAction)
35 //dynamic members
36 set this.m_checked = false
37 //members
38 set this.checkedImage = AImage.create(mainWindow, x, y, sizeX, sizeY, 0, 0)
39 call this.checkedImage.setFile(ACheckBox.uncheckedImageFilePath)
40 return this
41 endmethod
42
43 //static methods
44
45 public static method init0 takes string checkedImageFilePath, string uncheckedImageFilePath returns nothing
46 set ACheckBox.checkedImageFilePath = checkedImageFilePath
47 set ACheckBox.uncheckedImageFilePath = uncheckedImageFilePath
48 endmethod
49 endstruct
50
51 endlibrary